/**
 * Created by inna.ianko on 4/18/14.
 */

var chai = require('chai'), expect = chai.expect,
    wd = require('selenium-webdriver'), By = wd.By,
    PageNavigator = require('selenium-pageobject').PageNavigator,
    MyPage = require('./mypage.js');

var test_url = 'https://mail.google.com'
var test_user_name = 'JohnSmith'
var test_user_pass = 'password'

describe("MyPage", function() {
    var driver;
    var url = test_url;

    before(function(done) {
        driver = new wd.Builder().withCapabilities({'browserName': 'chrome', 'chromedriverpath': '../drivers/chrome/windows/chromedriver'}).build();
        done();
    });

    beforeEach(function(done) {
        driver.get(url);
        done();
    });

    it("should be able to login", function(done) {
        var pageNavigator = new PageNavigator({ driver: driver });
        var myPage = new MyPage(driver);

        pageNavigator.visit(url).then(function () {
            myPage.login(test_user_name, test_user_pass).then(function () {
                // expect something
            });
        }).then(function () {
                done();
            }).then(null, function (err) {
                done(err);
            });
    });

    after(function(done) {
        driver.quit().then(done);
    });
});
